using System;
using System.Collections.Generic;
using System.Text;

using DirectShowLib;
using DirectShowLib.DES;
using System.Runtime.InteropServices;

using OurMediaPlayer.Logic.Filters;

namespace OurMediaPlayer.Logic
{
    public class FiltersManager
    {
        public FiltersManager()
        {
            this.Filters = new List<Filter>();
        }

        public void AddFilter(Filter filter)
        {
            this.Filters.Add(filter);
        }

        public void RemoveFilter(Filter filter)
        {
            this.Filters.Remove(filter);
        }

        public void Clear()
        {
            this.Filters.Clear();
        }

        public void Process(double sampleTime, IntPtr pBuffer, int bufferLen, MediaInfo videoInfo)
        {
            byte[] copyBytes = new byte[bufferLen];

            Marshal.Copy(pBuffer, copyBytes, 0, bufferLen);

            if (this.currentFilter != null && this.currentFilter.Active == true)
                this.currentFilter.Process(copyBytes, pBuffer, videoInfo);
        }

        public Filter currentFilter;
        public List<Filter> Filters;
    }
}
